package cn.com.nes.site.service.system.user.impl;

import cn.com.nes.site.service.system.user.PushUserInfoService;
import cn.com.nes.site.service.system.user.PushUserInfoServiceFactory;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 推送用户账号信息工厂
 *
 * @Author: ShenWei
 * @Date: 2024/05/24/17:27
 */
@Service
public class PushUserInfoServiceFactoryImpl implements PushUserInfoServiceFactory {

    @Resource
    private List<PushUserInfoService> pushUserInfoServiceList;

    private static Map<Integer, PushUserInfoService> pushUserInfoServiceMap;

    @PostConstruct
    private void init() {
        pushUserInfoServiceMap = pushUserInfoServiceList.stream().collect(Collectors.toMap(PushUserInfoService::getPushType, t -> t));
    }

    @Override
    public PushUserInfoService getPushUserInfoService(Integer pushType) {
        return pushUserInfoServiceMap.get(pushType);
    }
}
